package com.wms.common;

import lombok.Data;

/**
 * ClassName: Result
 * Package: com.wms.common
 * Description:
 *
 * @Author Jerry
 * @Create 2025-02-01 23:34
 * @Version 1.0
 */
@Data
public class Result {
    private int code;//编码 200/400
    private String msg;//成功/失败
    private long total;//数据总数
    private Object data;//数据

    public static Result fail(){
        return  result(400,"失败",0,null);
    }

    public static Result suc(){
        return  result(200,"成功",0,null);
    }

    public static Result suc(Object data){
        return  result(200,"成功",0,data);
    }

    public static Result suc(Object data, long total){
        return  result(200,"成功",total,data);
    }

    private static Result result(int code,String msg,long  total,Object data){
        Result res = new Result();
        res.setCode(code);
        res.setMsg(msg);
        res.setTotal(total);
        res.setData(data);
        return res;
    }
}
